﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Collections.ObjectModel;

namespace Airport
{
    [ServiceContract(SessionMode=SessionMode.Required,
        CallbackContract=typeof(IAirportCallback))]
    public interface IAirportService
    {
        [OperationContract(IsOneWay = true)]
        void RegisterForFlightUpdates();
        [OperationContract(IsOneWay = true)]
        void UnregisterForFlightUpdates();

        [OperationContract(IsOneWay = true)]
        void RegisterForPlaneUpdates();
        [OperationContract(IsOneWay = true)]
        void UnregisterForPlaneUpdates();

        [OperationContract(IsOneWay = true)]
        void RegisterForIncursionDetectedUpdates();
        [OperationContract(IsOneWay = true)]
        void UnregisterForIncursionDetectedUpdates();

        // Method to get airport layout on startup
        [OperationContract(IsOneWay = true)]
        void GetAirportLayout();

        [OperationContract(IsOneWay = true)]
        void GetCurrentPlaneList();

        [OperationContract(IsOneWay = false)]
        Map GetAirportLayoutReqestReply();

        [OperationContract(IsOneWay = true)]
        void GetSuggestion(Plane updatedPlane, Node destinationNode, bool returnMitigation);

        [OperationContract(IsOneWay = true)]
        void AcceptRoute(Route acceptedRoute);

        /// <summary>
        /// Remove the Route that had been previously assigned to planeRouteToCancel.
        /// </summary>
        /// <param name="suggestionToCancel"></param>
        /// <returns>True if routeToCancel was found and removed. False otherwise.</returns>
        [OperationContract(IsOneWay = false)]
        bool CancelRoute(Plane planeRouteToCancel);

        [OperationContract(IsOneWay = true)]
        void ClearPlaneForTakeoff(Plane plane, string runway);

        [OperationContract(IsOneWay = true)]
        void ClearPlaneForLanding(Plane plane, string runway);

        void CalculateAndAcceptSuggestion(Plane updatedPlane, Node destinationNode);

        [OperationContract(IsOneWay = true)]
        void VerifyRouteString(List<string> routeStrings, bool overrideAccessibleEdges);

        // Scenario-related Methods
        [OperationContract(IsOneWay = true)]
        void GetScenarioList();
        [OperationContract(IsOneWay = true)]
        void LoadScenario(int scenarioNumber);

        void UpdatePlanePosition(Plane updatedPlane);
        void UpdateAllPlanePositions();

        double MapScaleFactor { get; }
        List<Node> AirportNodes { get; set; }
        List<Edge> AirportEdges { get; set; }
        List<Plane> ActivePlanes { get; set; }
    }    
}
